﻿namespace WMS6.Web.Configuration
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;
    using WMS6.Web.BaseInfoDetailServiceRef;
    using WMS6.Web.BaseInfoServiceRef;

    public class LotTemplate : BasePage
    {
        protected Button btnCopy;
        protected Button btnDelete;
        protected Button btnGoBack;
        protected Button btnNew;
        protected Button btnSave;
        protected CheckBox chkIsActive;
        protected CheckBox chkLotMandatory01;
        protected CheckBox chkLotMandatory02;
        protected CheckBox chkLotMandatory03;
        protected CheckBox chkLotMandatory04;
        protected CheckBox chkLotMandatory05;
        protected CheckBox chkLotMandatory06;
        protected CheckBox chkLotMandatory07;
        protected CheckBox chkLotMandatory08;
        protected CheckBox chkLotMandatory09;
        protected CheckBox chkLotMandatory10;
        protected CheckBox chkLotMandatory11;
        protected CheckBox chkLotMandatory12;
        protected CheckBox chkLotMandatory13;
        protected CheckBox chkLotMandatoryOT01;
        protected CheckBox chkLotMandatoryOT02;
        protected CheckBox chkLotMandatoryOT03;
        protected CheckBox chkLotMandatoryOT04;
        protected CheckBox chkLotMandatoryOT05;
        protected CheckBox chkLotMandatoryOT06;
        protected CheckBox chkLotMandatoryOT07;
        protected CheckBox chkLotMandatoryOT08;
        protected CheckBox chkLotMandatoryOT09;
        protected CheckBox chkLotMandatoryOT10;
        protected CheckBox chkLotMandatoryOT11;
        protected CheckBox chkLotMandatoryOT12;
        protected CheckBox chkLotMandatoryOT13;
        protected CheckBox chkLotRFVisible01;
        protected CheckBox chkLotRFVisible02;
        protected CheckBox chkLotRFVisible03;
        protected CheckBox chkLotRFVisible04;
        protected CheckBox chkLotRFVisible05;
        protected CheckBox chkLotRFVisible06;
        protected CheckBox chkLotRFVisible07;
        protected CheckBox chkLotRFVisible08;
        protected CheckBox chkLotRFVisible09;
        protected CheckBox chkLotRFVisible10;
        protected CheckBox chkLotRFVisible11;
        protected CheckBox chkLotRFVisible12;
        protected CheckBox chkLotRFVisible13;
        protected CheckBox chkLotVisible01;
        protected CheckBox chkLotVisible02;
        protected CheckBox chkLotVisible03;
        protected CheckBox chkLotVisible04;
        protected CheckBox chkLotVisible05;
        protected CheckBox chkLotVisible06;
        protected CheckBox chkLotVisible07;
        protected CheckBox chkLotVisible08;
        protected CheckBox chkLotVisible09;
        protected CheckBox chkLotVisible10;
        protected CheckBox chkLotVisible11;
        protected CheckBox chkLotVisible12;
        protected CheckBox chkLotVisible13;
        protected CheckBox chkSubLotRFVisible01;
        protected CheckBox chkSubLotRFVisible02;
        protected CheckBox chkSubLotRFVisible03;
        protected CheckBox chkSubLotRFVisible04;
        protected CheckBox chkSubLotRFVisible05;
        protected CheckBox chkSubLotRFVisible06;
        protected CheckBox chkSubLotRFVisible07;
        protected CheckBox chkSubLotRFVisible08;
        protected CheckBox chkSubLotRFVisible09;
        protected CheckBox chkSubLotRFVisible10;
        protected CheckBox chkSubLotRFVisible11;
        protected CheckBox chkSubLotRFVisible12;
        protected CheckBox chkSubLotRFVisible13;
        protected CheckBox chkSubLotVisible01;
        protected CheckBox chkSubLotVisible02;
        protected CheckBox chkSubLotVisible03;
        protected CheckBox chkSubLotVisible04;
        protected CheckBox chkSubLotVisible05;
        protected CheckBox chkSubLotVisible06;
        protected CheckBox chkSubLotVisible07;
        protected CheckBox chkSubLotVisible08;
        protected CheckBox chkSubLotVisible09;
        protected CheckBox chkSubLotVisible10;
        protected CheckBox chkSubLotVisible11;
        protected CheckBox chkSubLotVisible12;
        protected CheckBox chkSubLotVisible13;
        protected CheckBox chkSysCreated;
        protected DropDownList ddlDefaultIN01;
        protected DropDownList ddlDefaultIN02;
        protected DropDownList ddlDefaultIN03;
        protected DropDownList ddlDefaultIN04;
        protected DropDownList ddlDefaultIN05;
        protected DropDownList ddlDefaultIN06;
        protected DropDownList ddlDefaultIN07;
        protected DropDownList ddlDefaultIN08;
        protected DropDownList ddlDefaultIN09;
        protected DropDownList ddlDefaultIN10;
        protected DropDownList ddlDefaultOT01;
        protected DropDownList ddlDefaultOT02;
        protected DropDownList ddlDefaultOT03;
        protected DropDownList ddlDefaultOT04;
        protected DropDownList ddlDefaultOT05;
        protected DropDownList ddlDefaultOT06;
        protected DropDownList ddlDefaultOT07;
        protected DropDownList ddlDefaultOT08;
        protected DropDownList ddlDefaultOT09;
        protected DropDownList ddlDefaultOT10;
        protected DropDownList ddlLotType01;
        protected DropDownList ddlLotType02;
        protected DropDownList ddlLotType03;
        protected DropDownList ddlLotType04;
        protected DropDownList ddlLotType05;
        protected DropDownList ddlLotType06;
        protected DropDownList ddlLotType07;
        protected DropDownList ddlLotType08;
        protected DropDownList ddlLotType09;
        protected DropDownList ddlLotType10;
        protected DropDownList ddlLotValue01;
        protected DropDownList ddlLotValue02;
        protected DropDownList ddlLotValue03;
        protected DropDownList ddlLotValue04;
        protected DropDownList ddlLotValue05;
        protected DropDownList ddlLotValue06;
        protected DropDownList ddlLotValue07;
        protected DropDownList ddlLotValue08;
        protected DropDownList ddlLotValue09;
        protected DropDownList ddlLotValue10;
        protected HtmlForm F2081;
        protected HtmlInputHidden hdnFrom;
        protected HtmlInputHidden hdnLotTemplateID;
        protected Label lblDefaultIN;
        protected Label lblDefaultOT;
        protected Label lblDescription;
        protected Label lblDispalyName;
        protected Label lblExternal;
        protected Label lblLot01;
        protected Label lblLot02;
        protected Label lblLot03;
        protected Label lblLot04;
        protected Label lblLot05;
        protected Label lblLot06;
        protected Label lblLot07;
        protected Label lblLot08;
        protected Label lblLot09;
        protected Label lblLot10;
        protected Label lblLot11;
        protected Label lblLot12;
        protected Label lblLotTemplate;
        protected Label lblLotTemplateID;
        protected Label lblMandatory;
        protected Label lblMandatoryOT;
        protected Label lblMsg;
        protected Label lblRFVisible;
        protected Label lblSeqNo;
        protected Label lblType;
        protected Label lblValue;
        protected Label lblVisible;
        protected HtmlLink mycss;
        protected Label one1;
        protected ScriptManager ScriptManager1;
        private List<WMS6.Web.CommonMethodServiceRef.SysCode4DDL> sysCodeLotAttrType;
        private List<string> sysCodeLotAttrValue;
        protected TextBox txtDefaultIN01;
        protected TextBox txtDefaultIN02;
        protected TextBox txtDefaultIN03;
        protected TextBox txtDefaultIN04;
        protected TextBox txtDefaultIN05;
        protected TextBox txtDefaultIN06;
        protected TextBox txtDefaultIN07;
        protected TextBox txtDefaultIN08;
        protected TextBox txtDefaultIN09;
        protected TextBox txtDefaultIN10;
        protected TextBox txtDefaultOT01;
        protected TextBox txtDefaultOT02;
        protected TextBox txtDefaultOT03;
        protected TextBox txtDefaultOT04;
        protected TextBox txtDefaultOT05;
        protected TextBox txtDefaultOT06;
        protected TextBox txtDefaultOT07;
        protected TextBox txtDefaultOT08;
        protected TextBox txtDefaultOT09;
        protected TextBox txtDefaultOT10;
        protected TextBox txtDescription;
        protected TextBox txtExpiryDate;
        protected TextBox txtExternal;
        protected TextBox txtLot01;
        protected TextBox txtLot02;
        protected TextBox txtLot03;
        protected TextBox txtLot04;
        protected TextBox txtLot05;
        protected TextBox txtLot06;
        protected TextBox txtLot07;
        protected TextBox txtLot08;
        protected TextBox txtLot09;
        protected TextBox txtLot10;
        protected TextBox txtLotTemplateID;
        protected TextBox txtLotValue01;
        protected TextBox txtLotValue02;
        protected TextBox txtLotValue03;
        protected TextBox txtLotValue04;
        protected TextBox txtLotValue05;
        protected TextBox txtLotValue06;
        protected TextBox txtLotValue07;
        protected TextBox txtLotValue08;
        protected TextBox txtLotValue09;
        protected TextBox txtLotValue10;
        protected TextBox txtProduct;
        protected TextBox txtSeqNo1;
        protected TextBox txtSeqNo10;
        protected TextBox txtSeqNo11;
        protected TextBox txtSeqNo12;
        protected TextBox txtSeqNo13;
        protected TextBox txtSeqNo2;
        protected TextBox txtSeqNo3;
        protected TextBox txtSeqNo4;
        protected TextBox txtSeqNo5;
        protected TextBox txtSeqNo6;
        protected TextBox txtSeqNo7;
        protected TextBox txtSeqNo8;
        protected TextBox txtSeqNo9;
        protected UpdatePanel up1;

        protected void btnCopy_Click(object sender, EventArgs e)
        {
            this.txtLotTemplateID.Text = "";
            this.txtLotTemplateID.Enabled = true;
            this.hdnLotTemplateID.Value = "";
            this.chkSysCreated.Checked = false;
            base.DataEntityViewState = null;
        }

        protected void btnDelete_Click(object sender, EventArgs e)
        {
            if (this.chkSysCreated.Checked)
            {
                this.lblMsg.Text = base.GetGlobalMsgResource("C011");
            }
            else if (!string.IsNullOrEmpty(this.txtLotTemplateID.Text.Trim()))
            {
                try
                {
                    List<string> lotTemplateID = new List<string> {
                        this.txtLotTemplateID.Text.Trim()
                    };
                    this.lblMsg.Text = BaseInfoServiceClientProxy.GetInstance().Delete(lotTemplateID, "LOT_TEMPLATE") + base.GetGlobalMsgResource("C006");
                    this.btnSave.Enabled = false;
                    this.btnDelete.Enabled = false;
                    this.btnCopy.Enabled = false;
                    base.DataEntityViewState = null;
                }
                catch (Exception ex)
                {
                    this.lblMsg.Text = base.GetGlobalMsgResource("C007") + ex.Message;
                }
            }
        }

        protected void btnGoBack_Click(object sender, EventArgs e)
        {
            switch (this.hdnFrom.Value)
            {
                case "query":
                    base.Response.Redirect("LotTemplateQuery.aspx", false);
                    break;

                case "list":
                    base.Response.Redirect("LotTemplateList.aspx?from=edit", false);
                    break;
            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.txtLotTemplateID.Text.Trim()))
            {
                this.lblMsg.Text = base.GetGlobalMsgResource("F2081_001");
            }
            else if (((this.chkLotVisible01.Checked || this.chkLotMandatory01.Checked) || this.chkLotMandatoryOT01.Checked) && string.IsNullOrEmpty(this.txtLot01.Text.Trim()))
            {
                this.lblMsg.Text = string.Format(base.GetGlobalMsgResource("F2081_002"), this.lblLot01.Text, this.lblDispalyName.Text);
                this.txtLot01.Focus();
            }
            else if (((this.chkLotVisible02.Checked || this.chkLotMandatory02.Checked) || this.chkLotMandatoryOT02.Checked) && string.IsNullOrEmpty(this.txtLot02.Text.Trim()))
            {
                this.lblMsg.Text = string.Format(base.GetGlobalMsgResource("F2081_002"), this.lblLot02.Text, this.lblDispalyName.Text);
                this.txtLot02.Focus();
            }
            else if (((this.chkLotVisible03.Checked || this.chkLotMandatory03.Checked) || this.chkLotMandatoryOT03.Checked) && string.IsNullOrEmpty(this.txtLot03.Text.Trim()))
            {
                this.lblMsg.Text = string.Format(base.GetGlobalMsgResource("F2081_002"), this.lblLot03.Text, this.lblDispalyName.Text);
                this.txtLot03.Focus();
            }
            else if (((this.chkLotVisible04.Checked || this.chkLotMandatory04.Checked) || this.chkLotMandatoryOT04.Checked) && string.IsNullOrEmpty(this.txtLot04.Text.Trim()))
            {
                this.lblMsg.Text = string.Format(base.GetGlobalMsgResource("F2081_002"), this.lblLot04.Text, this.lblDispalyName.Text);
                this.txtLot04.Focus();
            }
            else if (((this.chkLotVisible05.Checked || this.chkLotMandatory05.Checked) || this.chkLotMandatoryOT05.Checked) && string.IsNullOrEmpty(this.txtLot05.Text.Trim()))
            {
                this.lblMsg.Text = string.Format(base.GetGlobalMsgResource("F2081_002"), this.lblLot05.Text, this.lblDispalyName.Text);
                this.txtLot05.Focus();
            }
            else if (((this.chkLotVisible06.Checked || this.chkLotMandatory06.Checked) || this.chkLotMandatoryOT06.Checked) && string.IsNullOrEmpty(this.txtLot06.Text.Trim()))
            {
                this.lblMsg.Text = string.Format(base.GetGlobalMsgResource("F2081_002"), this.lblLot06.Text, this.lblDispalyName.Text);
                this.txtLot06.Focus();
            }
            else if (((this.chkLotVisible07.Checked || this.chkLotMandatory07.Checked) || this.chkLotMandatoryOT07.Checked) && string.IsNullOrEmpty(this.txtLot07.Text.Trim()))
            {
                this.lblMsg.Text = string.Format(base.GetGlobalMsgResource("F2081_002"), this.lblLot07.Text, this.lblDispalyName.Text);
                this.txtLot07.Focus();
            }
            else if (((this.chkLotVisible08.Checked || this.chkLotMandatory08.Checked) || this.chkLotMandatoryOT08.Checked) && string.IsNullOrEmpty(this.txtLot08.Text.Trim()))
            {
                this.lblMsg.Text = string.Format(base.GetGlobalMsgResource("F2081_002"), this.lblLot08.Text, this.lblDispalyName.Text);
                this.txtLot08.Focus();
            }
            else if (((this.chkLotVisible09.Checked || this.chkLotMandatory09.Checked) || this.chkLotMandatoryOT09.Checked) && string.IsNullOrEmpty(this.txtLot09.Text.Trim()))
            {
                this.lblMsg.Text = string.Format(base.GetGlobalMsgResource("F2081_002"), this.lblLot09.Text, this.lblDispalyName.Text);
                this.txtLot09.Focus();
            }
            else if (((this.chkLotVisible10.Checked || this.chkLotMandatory10.Checked) || this.chkLotMandatoryOT10.Checked) && string.IsNullOrEmpty(this.txtLot10.Text.Trim()))
            {
                this.lblMsg.Text = string.Format(base.GetGlobalMsgResource("F2081_002"), this.lblLot10.Text, this.lblDispalyName.Text);
                this.txtLot10.Focus();
            }
            else if (((this.chkLotVisible11.Checked || this.chkLotMandatory11.Checked) || this.chkLotMandatoryOT11.Checked) && string.IsNullOrEmpty(this.txtProduct.Text.Trim()))
            {
                this.lblMsg.Text = string.Format(base.GetGlobalMsgResource("F2081_002"), this.lblLot11.Text, this.lblDispalyName.Text);
                this.txtProduct.Focus();
            }
            else if (((this.chkLotVisible12.Checked || this.chkLotMandatory12.Checked) || this.chkLotMandatoryOT12.Checked) && string.IsNullOrEmpty(this.txtExpiryDate.Text.Trim()))
            {
                this.lblMsg.Text = string.Format(base.GetGlobalMsgResource("F2081_002"), this.lblLot12.Text, this.lblDispalyName.Text);
                this.txtExpiryDate.Focus();
            }
            else if (((this.chkLotVisible13.Checked || this.chkLotMandatory13.Checked) || this.chkLotMandatoryOT13.Checked) && string.IsNullOrEmpty(this.txtExternal.Text.Trim()))
            {
                this.lblMsg.Text = string.Format(base.GetGlobalMsgResource("F2081_002"), this.lblExternal.Text, this.lblDispalyName.Text);
                this.txtExternal.Focus();
            }
            else
            {
                if (base.DataEntityViewState != null)
                {
                    this.UpdateLotTemplateInfo();
                }
                else
                {
                    this.InsertLotTemplateInfo();
                }
                this.SetLotTemplateInfo2Form();
            }
        }

        protected void ddlLotType_TextChanged(object sender, EventArgs e)
        {
            DropDownList LotValue = (DropDownList) sender;
            string ddl = LotValue.ID.Substring(LotValue.ID.Length - 2, 2);
            if (LotValue.SelectedValue == "OptionList")
            {
                ((DropDownList) this.FindControl("ddlLotValue" + ddl)).Style["display"] = "block";
                ((TextBox) this.FindControl("txtLotValue" + ddl)).Style["display"] = "none";
                ((DropDownList) this.FindControl("ddlDefaultIN" + ddl)).Style["display"] = "block";
                ((TextBox) this.FindControl("txtDefaultIN" + ddl)).Style["display"] = "none";
                ((DropDownList) this.FindControl("ddlDefaultOT" + ddl)).Style["display"] = "block";
                ((TextBox) this.FindControl("txtDefaultOT" + ddl)).Style["display"] = "none";
            }
            else
            {
                ((DropDownList) this.FindControl("ddlLotValue" + ddl)).Style["display"] = "none";
                ((TextBox) this.FindControl("txtLotValue" + ddl)).Style["display"] = "block";
                ((DropDownList) this.FindControl("ddlDefaultIN" + ddl)).Style["display"] = "none";
                ((TextBox) this.FindControl("txtDefaultIN" + ddl)).Style["display"] = "block";
                ((DropDownList) this.FindControl("ddlDefaultOT" + ddl)).Style["display"] = "none";
                ((TextBox) this.FindControl("txtDefaultOT" + ddl)).Style["display"] = "block";
            }
        }

        protected void ddlLotValue_TextChanged(object sender, EventArgs e)
        {
            DropDownList LotValue = (DropDownList) sender;
            switch (LotValue.ID)
            {
                case "ddlLotValue01":
                    this.InitLotAttrValueDefaultINOTDDL(this.ddlDefaultIN01, this.ddlDefaultOT01, LotValue.SelectedValue);
                    break;

                case "ddlLotValue02":
                    this.InitLotAttrValueDefaultINOTDDL(this.ddlDefaultIN02, this.ddlDefaultOT02, LotValue.SelectedValue);
                    break;

                case "ddlLotValue03":
                    this.InitLotAttrValueDefaultINOTDDL(this.ddlDefaultIN03, this.ddlDefaultOT03, LotValue.SelectedValue);
                    break;

                case "ddlLotValue04":
                    this.InitLotAttrValueDefaultINOTDDL(this.ddlDefaultIN04, this.ddlDefaultOT04, LotValue.SelectedValue);
                    break;

                case "ddlLotValue05":
                    this.InitLotAttrValueDefaultINOTDDL(this.ddlDefaultIN05, this.ddlDefaultOT05, LotValue.SelectedValue);
                    break;

                case "ddlLotValue06":
                    this.InitLotAttrValueDefaultINOTDDL(this.ddlDefaultIN06, this.ddlDefaultOT06, LotValue.SelectedValue);
                    break;

                case "ddlLotValue07":
                    this.InitLotAttrValueDefaultINOTDDL(this.ddlDefaultIN07, this.ddlDefaultOT07, LotValue.SelectedValue);
                    break;

                case "ddlLotValue08":
                    this.InitLotAttrValueDefaultINOTDDL(this.ddlDefaultIN08, this.ddlDefaultOT08, LotValue.SelectedValue);
                    break;

                case "ddlLotValue09":
                    this.InitLotAttrValueDefaultINOTDDL(this.ddlDefaultIN09, this.ddlDefaultOT09, LotValue.SelectedValue);
                    break;

                case "ddlLotValue10":
                    this.InitLotAttrValueDefaultINOTDDL(this.ddlDefaultIN10, this.ddlDefaultOT10, LotValue.SelectedValue);
                    break;
            }
        }

        private LotTemplateInfo GetLotTemplateInfo4Form(LotTemplateInfo lotTemplateInfo)
        {
            int tempInt = 0;
            lotTemplateInfo.LotTemplateID = this.txtLotTemplateID.Text.Trim();
            lotTemplateInfo.Description = this.txtDescription.Text.Trim();
            lotTemplateInfo.SystemCreated = this.chkSysCreated.Checked ? "Y" : "N";
            lotTemplateInfo.IsActive = this.chkIsActive.Checked ? "Y" : "N";
            if (int.TryParse(this.txtSeqNo1.Text.Trim(), out tempInt))
            {
                lotTemplateInfo.LotAttr01Seqno = int.Parse(this.txtSeqNo1.Text.Trim());
            }
            else
            {
                lotTemplateInfo.LotAttr01Seqno = tempInt;
            }
            lotTemplateInfo.LotAttr01Label = this.txtLot01.Text.Trim();
            lotTemplateInfo.LotAttr01Visible = this.chkLotVisible01.Checked ? "Y" : "N";
            lotTemplateInfo.RfLotAttr01Visible = this.chkLotRFVisible01.Checked ? "Y" : "N";
            lotTemplateInfo.LotAttr01Mandatory = this.chkLotMandatory01.Checked ? "Y" : "N";
            lotTemplateInfo.LotAttr01MandatoryOT = this.chkLotMandatoryOT01.Checked ? "Y" : "N";
            lotTemplateInfo.LotAttr01Type = this.ddlLotType01.SelectedValue;
            lotTemplateInfo.LotAttr01Value = (this.ddlLotType01.SelectedValue == "OptionList") ? this.ddlLotValue01.SelectedValue : this.txtLotValue01.Text.Trim();
            lotTemplateInfo.LotAttr01ValueDefaultIN = (this.ddlLotType01.SelectedValue == "OptionList") ? this.ddlDefaultIN01.SelectedValue : this.txtDefaultIN01.Text.Trim();
            lotTemplateInfo.LotAttr01ValueDefaultOT = (this.ddlLotType01.SelectedValue == "OptionList") ? this.ddlDefaultOT01.SelectedValue : this.txtDefaultOT01.Text.Trim();
            if (int.TryParse(this.txtSeqNo2.Text.Trim(), out tempInt))
            {
                lotTemplateInfo.LotAttr02Seqno = int.Parse(this.txtSeqNo2.Text.Trim());
            }
            else
            {
                lotTemplateInfo.LotAttr02Seqno = tempInt;
            }
            lotTemplateInfo.LotAttr02Label = this.txtLot02.Text.Trim();
            lotTemplateInfo.LotAttr02Visible = this.chkLotVisible02.Checked ? "Y" : "N";
            lotTemplateInfo.RfLotAttr02Visible = this.chkLotRFVisible02.Checked ? "Y" : "N";
            lotTemplateInfo.LotAttr02Mandatory = this.chkLotMandatory02.Checked ? "Y" : "N";
            lotTemplateInfo.LotAttr02MandatoryOT = this.chkLotMandatoryOT02.Checked ? "Y" : "N";
            lotTemplateInfo.LotAttr02Type = this.ddlLotType02.SelectedValue;
            lotTemplateInfo.LotAttr02Value = (this.ddlLotType02.SelectedValue == "OptionList") ? this.ddlLotValue02.SelectedValue : this.txtLotValue02.Text.Trim();
            lotTemplateInfo.LotAttr02ValueDefaultIN = (this.ddlLotType02.SelectedValue == "OptionList") ? this.ddlDefaultIN02.SelectedValue : this.txtDefaultIN02.Text.Trim();
            lotTemplateInfo.LotAttr02ValueDefaultOT = (this.ddlLotType02.SelectedValue == "OptionList") ? this.ddlDefaultOT02.SelectedValue : this.txtDefaultOT02.Text.Trim();
            if (int.TryParse(this.txtSeqNo3.Text.Trim(), out tempInt))
            {
                lotTemplateInfo.LotAttr03Seqno = int.Parse(this.txtSeqNo3.Text.Trim());
            }
            else
            {
                lotTemplateInfo.LotAttr03Seqno = tempInt;
            }
            lotTemplateInfo.LotAttr03Label = this.txtLot03.Text.Trim();
            lotTemplateInfo.LotAttr03Visible = this.chkLotVisible03.Checked ? "Y" : "N";
            lotTemplateInfo.RfLotAttr03Visible = this.chkLotRFVisible03.Checked ? "Y" : "N";
            lotTemplateInfo.LotAttr03Mandatory = this.chkLotMandatory03.Checked ? "Y" : "N";
            lotTemplateInfo.LotAttr03MandatoryOT = this.chkLotMandatoryOT03.Checked ? "Y" : "N";
            lotTemplateInfo.LotAttr03Type = this.ddlLotType03.SelectedValue;
            lotTemplateInfo.LotAttr03Value = (this.ddlLotType03.SelectedValue == "OptionList") ? this.ddlLotValue03.SelectedValue : this.txtLotValue03.Text.Trim();
            lotTemplateInfo.LotAttr03ValueDefaultIN = (this.ddlLotType03.SelectedValue == "OptionList") ? this.ddlDefaultIN03.SelectedValue : this.txtDefaultIN03.Text.Trim();
            lotTemplateInfo.LotAttr03ValueDefaultOT = (this.ddlLotType03.SelectedValue == "OptionList") ? this.ddlDefaultOT03.SelectedValue : this.txtDefaultOT03.Text.Trim();
            if (int.TryParse(this.txtSeqNo4.Text.Trim(), out tempInt))
            {
                lotTemplateInfo.LotAttr04Seqno = int.Parse(this.txtSeqNo4.Text.Trim());
            }
            else
            {
                lotTemplateInfo.LotAttr04Seqno = tempInt;
            }
            lotTemplateInfo.LotAttr04Label = this.txtLot04.Text.Trim();
            lotTemplateInfo.LotAttr04Visible = this.chkLotVisible04.Checked ? "Y" : "N";
            lotTemplateInfo.RfLotAttr04Visible = this.chkLotRFVisible04.Checked ? "Y" : "N";
            lotTemplateInfo.LotAttr04Mandatory = this.chkLotMandatory04.Checked ? "Y" : "N";
            lotTemplateInfo.LotAttr04MandatoryOT = this.chkLotMandatoryOT04.Checked ? "Y" : "N";
            lotTemplateInfo.LotAttr04Type = this.ddlLotType04.SelectedValue;
            lotTemplateInfo.LotAttr04Value = (this.ddlLotType04.SelectedValue == "OptionList") ? this.ddlLotValue04.SelectedValue : this.txtLotValue04.Text.Trim();
            lotTemplateInfo.LotAttr04ValueDefaultIN = (this.ddlLotType04.SelectedValue == "OptionList") ? this.ddlDefaultIN04.SelectedValue : this.txtDefaultIN04.Text.Trim();
            lotTemplateInfo.LotAttr04ValueDefaultOT = (this.ddlLotType04.SelectedValue == "OptionList") ? this.ddlDefaultOT04.SelectedValue : this.txtDefaultOT04.Text.Trim();
            if (int.TryParse(this.txtSeqNo5.Text.Trim(), out tempInt))
            {
                lotTemplateInfo.LotAttr05Seqno = int.Parse(this.txtSeqNo5.Text.Trim());
            }
            else
            {
                lotTemplateInfo.LotAttr05Seqno = tempInt;
            }
            lotTemplateInfo.LotAttr05Label = this.txtLot05.Text.Trim();
            lotTemplateInfo.LotAttr05Visible = this.chkLotVisible05.Checked ? "Y" : "N";
            lotTemplateInfo.RfLotAttr05Visible = this.chkLotRFVisible05.Checked ? "Y" : "N";
            lotTemplateInfo.LotAttr05Mandatory = this.chkLotMandatory05.Checked ? "Y" : "N";
            lotTemplateInfo.LotAttr05MandatoryOT = this.chkLotMandatoryOT05.Checked ? "Y" : "N";
            lotTemplateInfo.LotAttr05Type = this.ddlLotType05.SelectedValue;
            lotTemplateInfo.LotAttr05Value = (this.ddlLotType05.SelectedValue == "OptionList") ? this.ddlLotValue05.SelectedValue : this.txtLotValue05.Text.Trim();
            lotTemplateInfo.LotAttr05ValueDefaultIN = (this.ddlLotType05.SelectedValue == "OptionList") ? this.ddlDefaultIN05.SelectedValue : this.txtDefaultIN05.Text.Trim();
            lotTemplateInfo.LotAttr05ValueDefaultOT = (this.ddlLotType05.SelectedValue == "OptionList") ? this.ddlDefaultOT05.SelectedValue : this.txtDefaultOT05.Text.Trim();
            if (int.TryParse(this.txtSeqNo6.Text.Trim(), out tempInt))
            {
                lotTemplateInfo.LotAttr06Seqno = int.Parse(this.txtSeqNo6.Text.Trim());
            }
            else
            {
                lotTemplateInfo.LotAttr06Seqno = tempInt;
            }
            lotTemplateInfo.LotAttr06Label = this.txtLot06.Text.Trim();
            lotTemplateInfo.LotAttr06Visible = this.chkLotVisible06.Checked ? "Y" : "N";
            lotTemplateInfo.RfLotAttr06Visible = this.chkLotRFVisible06.Checked ? "Y" : "N";
            lotTemplateInfo.LotAttr06Mandatory = this.chkLotMandatory06.Checked ? "Y" : "N";
            lotTemplateInfo.LotAttr06MandatoryOT = this.chkLotMandatoryOT06.Checked ? "Y" : "N";
            lotTemplateInfo.LotAttr06Type = this.ddlLotType06.SelectedValue;
            lotTemplateInfo.LotAttr06Value = (this.ddlLotType06.SelectedValue == "OptionList") ? this.ddlLotValue06.SelectedValue : this.txtLotValue06.Text.Trim();
            lotTemplateInfo.LotAttr06ValueDefaultIN = (this.ddlLotType06.SelectedValue == "OptionList") ? this.ddlDefaultIN06.SelectedValue : this.txtDefaultIN06.Text.Trim();
            lotTemplateInfo.LotAttr06ValueDefaultOT = (this.ddlLotType06.SelectedValue == "OptionList") ? this.ddlDefaultOT06.SelectedValue : this.txtDefaultOT06.Text.Trim();
            if (int.TryParse(this.txtSeqNo7.Text.Trim(), out tempInt))
            {
                lotTemplateInfo.LotAttr07Seqno = int.Parse(this.txtSeqNo7.Text.Trim());
            }
            else
            {
                lotTemplateInfo.LotAttr07Seqno = tempInt;
            }
            lotTemplateInfo.LotAttr07Label = this.txtLot07.Text.Trim();
            lotTemplateInfo.LotAttr07Visible = this.chkLotVisible07.Checked ? "Y" : "N";
            lotTemplateInfo.RfLotAttr07Visible = this.chkLotRFVisible07.Checked ? "Y" : "N";
            lotTemplateInfo.LotAttr07Mandatory = this.chkLotMandatory07.Checked ? "Y" : "N";
            lotTemplateInfo.LotAttr07MandatoryOT = this.chkLotMandatoryOT07.Checked ? "Y" : "N";
            lotTemplateInfo.LotAttr07Type = this.ddlLotType07.SelectedValue;
            lotTemplateInfo.LotAttr07Value = (this.ddlLotType07.SelectedValue == "OptionList") ? this.ddlLotValue07.SelectedValue : this.txtLotValue07.Text.Trim();
            lotTemplateInfo.LotAttr07ValueDefaultIN = (this.ddlLotType07.SelectedValue == "OptionList") ? this.ddlDefaultIN07.SelectedValue : this.txtDefaultIN07.Text.Trim();
            lotTemplateInfo.LotAttr07ValueDefaultOT = (this.ddlLotType07.SelectedValue == "OptionList") ? this.ddlDefaultOT07.SelectedValue : this.txtDefaultOT07.Text.Trim();
            if (int.TryParse(this.txtSeqNo8.Text.Trim(), out tempInt))
            {
                lotTemplateInfo.LotAttr08Seqno = int.Parse(this.txtSeqNo8.Text.Trim());
            }
            else
            {
                lotTemplateInfo.LotAttr08Seqno = tempInt;
            }
            lotTemplateInfo.LotAttr08Label = this.txtLot08.Text.Trim();
            lotTemplateInfo.LotAttr08Visible = this.chkLotVisible08.Checked ? "Y" : "N";
            lotTemplateInfo.RfLotAttr08Visible = this.chkLotRFVisible08.Checked ? "Y" : "N";
            lotTemplateInfo.LotAttr08Mandatory = this.chkLotMandatory08.Checked ? "Y" : "N";
            lotTemplateInfo.LotAttr08MandatoryOT = this.chkLotMandatoryOT08.Checked ? "Y" : "N";
            lotTemplateInfo.LotAttr08Type = this.ddlLotType08.SelectedValue;
            lotTemplateInfo.LotAttr08Value = (this.ddlLotType08.SelectedValue == "OptionList") ? this.ddlLotValue08.SelectedValue : this.txtLotValue08.Text.Trim();
            lotTemplateInfo.LotAttr08ValueDefaultIN = (this.ddlLotType08.SelectedValue == "OptionList") ? this.ddlDefaultIN08.SelectedValue : this.txtDefaultIN08.Text.Trim();
            lotTemplateInfo.LotAttr08ValueDefaultOT = (this.ddlLotType08.SelectedValue == "OptionList") ? this.ddlDefaultOT08.SelectedValue : this.txtDefaultOT08.Text.Trim();
            if (int.TryParse(this.txtSeqNo9.Text.Trim(), out tempInt))
            {
                lotTemplateInfo.LotAttr09Seqno = int.Parse(this.txtSeqNo9.Text.Trim());
            }
            else
            {
                lotTemplateInfo.LotAttr09Seqno = tempInt;
            }
            lotTemplateInfo.LotAttr09Label = this.txtLot09.Text.Trim();
            lotTemplateInfo.LotAttr09Visible = this.chkLotVisible09.Checked ? "Y" : "N";
            lotTemplateInfo.RfLotAttr09Visible = this.chkLotRFVisible09.Checked ? "Y" : "N";
            lotTemplateInfo.LotAttr09Mandatory = this.chkLotMandatory09.Checked ? "Y" : "N";
            lotTemplateInfo.LotAttr09MandatoryOT = this.chkLotMandatoryOT09.Checked ? "Y" : "N";
            lotTemplateInfo.LotAttr09Type = this.ddlLotType09.SelectedValue;
            lotTemplateInfo.LotAttr09Value = (this.ddlLotType09.SelectedValue == "OptionList") ? this.ddlLotValue09.SelectedValue : this.txtLotValue09.Text.Trim();
            lotTemplateInfo.LotAttr09ValueDefaultIN = (this.ddlLotType09.SelectedValue == "OptionList") ? this.ddlDefaultIN09.SelectedValue : this.txtDefaultIN09.Text.Trim();
            lotTemplateInfo.LotAttr09ValueDefaultOT = (this.ddlLotType09.SelectedValue == "OptionList") ? this.ddlDefaultOT09.SelectedValue : this.txtDefaultOT09.Text.Trim();
            if (int.TryParse(this.txtSeqNo10.Text.Trim(), out tempInt))
            {
                lotTemplateInfo.LotAttr10Seqno = int.Parse(this.txtSeqNo10.Text.Trim());
            }
            else
            {
                lotTemplateInfo.LotAttr10Seqno = tempInt;
            }
            lotTemplateInfo.LotAttr10Label = this.txtLot10.Text.Trim();
            lotTemplateInfo.LotAttr10Visible = this.chkLotVisible10.Checked ? "Y" : "N";
            lotTemplateInfo.RfLotAttr10Visible = this.chkLotRFVisible10.Checked ? "Y" : "N";
            lotTemplateInfo.LotAttr10Mandatory = this.chkLotMandatory10.Checked ? "Y" : "N";
            lotTemplateInfo.LotAttr10MandatoryOT = this.chkLotMandatoryOT10.Checked ? "Y" : "N";
            lotTemplateInfo.LotAttr10Type = this.ddlLotType10.SelectedValue;
            lotTemplateInfo.LotAttr10Value = (this.ddlLotType10.SelectedValue == "OptionList") ? this.ddlLotValue10.SelectedValue : this.txtLotValue10.Text.Trim();
            lotTemplateInfo.LotAttr10ValueDefaultIN = (this.ddlLotType10.SelectedValue == "OptionList") ? this.ddlDefaultIN10.SelectedValue : this.txtDefaultIN10.Text.Trim();
            lotTemplateInfo.LotAttr10ValueDefaultOT = (this.ddlLotType10.SelectedValue == "OptionList") ? this.ddlDefaultOT10.SelectedValue : this.txtDefaultOT10.Text.Trim();
            if (int.TryParse(this.txtSeqNo11.Text.Trim(), out tempInt))
            {
                lotTemplateInfo.ProduceDateSeqno = int.Parse(this.txtSeqNo11.Text.Trim());
            }
            else
            {
                lotTemplateInfo.ProduceDateSeqno = tempInt;
            }
            lotTemplateInfo.ProduceDateLabel = this.txtProduct.Text.Trim();
            lotTemplateInfo.ProduceDateVisible = this.chkLotVisible11.Checked ? "Y" : "N";
            lotTemplateInfo.RfProduceDateVisible = this.chkLotRFVisible11.Checked ? "Y" : "N";
            lotTemplateInfo.ProduceDateMandatory = this.chkLotMandatory11.Checked ? "Y" : "N";
            lotTemplateInfo.ProduceDateMandatoryOT = this.chkLotMandatoryOT11.Checked ? "Y" : "N";
            if (int.TryParse(this.txtSeqNo12.Text.Trim(), out tempInt))
            {
                lotTemplateInfo.ExpiryDateSeqno = int.Parse(this.txtSeqNo12.Text.Trim());
            }
            else
            {
                lotTemplateInfo.ExpiryDateSeqno = tempInt;
            }
            lotTemplateInfo.ExpiryDateLabel = this.txtExpiryDate.Text.Trim();
            lotTemplateInfo.ExpiryDateVisible = this.chkLotVisible12.Checked ? "Y" : "N";
            lotTemplateInfo.RfExpiryDateVisible = this.chkLotRFVisible12.Checked ? "Y" : "N";
            lotTemplateInfo.ExpiryDateMandatory = this.chkLotMandatory12.Checked ? "Y" : "N";
            lotTemplateInfo.ExpiryDateMandatoryOT = this.chkLotMandatoryOT12.Checked ? "Y" : "N";
            if (int.TryParse(this.txtSeqNo13.Text.Trim(), out tempInt))
            {
                lotTemplateInfo.ExternalLotSeqno = int.Parse(this.txtSeqNo13.Text.Trim());
            }
            else
            {
                lotTemplateInfo.ExternalLotSeqno = tempInt;
            }
            lotTemplateInfo.ExternalLotLabel = this.txtExternal.Text.Trim();
            lotTemplateInfo.ExternalLotVisible = this.chkLotVisible13.Checked ? "Y" : "N";
            lotTemplateInfo.RfExternalLotVisible = this.chkLotRFVisible13.Checked ? "Y" : "N";
            lotTemplateInfo.ExternalLotMandatory = this.chkLotMandatory13.Checked ? "Y" : "N";
            lotTemplateInfo.ExternalLotMandatoryOT = this.chkLotMandatoryOT13.Checked ? "Y" : "N";
            return lotTemplateInfo;
        }

        private void InitLotAttrTypeDDL(DropDownList ddl)
        {
            if (this.sysCodeLotAttrType == null)
            {
                this.sysCodeLotAttrType = CommoneMethodServiceClientProxy.GetInstance().GetSysCodeDataSource("LotAttrType");
            }
            ddl.DataSource = this.sysCodeLotAttrType;
            ddl.DataTextField = "SysCodeText";
            ddl.DataValueField = "SysCodeValue";
            ddl.DataBind();
        }

        private void InitLotAttrValueDDL(DropDownList ddl)
        {
            if (this.sysCodeLotAttrValue == null)
            {
                this.sysCodeLotAttrValue = CommoneMethodServiceClientProxy.GetInstance().GetLotAttributeCode4LotTemplate();
            }
            ddl.DataSource = this.sysCodeLotAttrValue;
            ddl.DataBind();
            this.ddlLotValue_TextChanged(ddl, null);
        }

        private void InitLotAttrValueDefaultINOTDDL(DropDownList ddlIN, DropDownList ddlOT, string key)
        {
            LotAttributeCodeQueryEntity lotAttributeCodeQuery = new LotAttributeCodeQueryEntity {
                GroupID = "='" + key + "'",
                IsGetAll = true
            };
            DataSet ds = new DataSet();
            ds = BaseInfoDetailServiceClientProxy.GetInstance().GetDetaiInfolByQueryEntity(lotAttributeCodeQuery, "LOT_ATTRIBUTE_CODE");
            ddlIN.DataSource = ds;
            ddlIN.DataValueField = "CODE_ID";
            ddlIN.DataTextField = "DESCR";
            ddlIN.DataBind();
            ddlIN.Items.Insert(0, new ListItem("-----", ""));
            ddlOT.DataSource = ds;
            ddlOT.DataValueField = "CODE_ID";
            ddlOT.DataTextField = "DESCR";
            ddlOT.DataBind();
            ddlOT.Items.Insert(0, new ListItem("-----", ""));
        }

        private void InitLotTemplateDropDownLit()
        {
            this.InitLotAttrTypeDDL(this.ddlLotType01);
            this.InitLotAttrTypeDDL(this.ddlLotType02);
            this.InitLotAttrTypeDDL(this.ddlLotType03);
            this.InitLotAttrTypeDDL(this.ddlLotType04);
            this.InitLotAttrTypeDDL(this.ddlLotType05);
            this.InitLotAttrTypeDDL(this.ddlLotType06);
            this.InitLotAttrTypeDDL(this.ddlLotType07);
            this.InitLotAttrTypeDDL(this.ddlLotType08);
            this.InitLotAttrTypeDDL(this.ddlLotType09);
            this.InitLotAttrTypeDDL(this.ddlLotType10);
            this.ddlLotType09.SelectedValue = "OptionList";
            this.InitLotAttrValueDDL(this.ddlLotValue01);
            this.InitLotAttrValueDDL(this.ddlLotValue02);
            this.InitLotAttrValueDDL(this.ddlLotValue03);
            this.InitLotAttrValueDDL(this.ddlLotValue04);
            this.InitLotAttrValueDDL(this.ddlLotValue05);
            this.InitLotAttrValueDDL(this.ddlLotValue06);
            this.InitLotAttrValueDDL(this.ddlLotValue07);
            this.InitLotAttrValueDDL(this.ddlLotValue08);
            this.InitLotAttrValueDDL(this.ddlLotValue09);
            this.InitLotAttrValueDDL(this.ddlLotValue10);
            this.ddlLotValue09.Text = "货品属性";
        }

        private void InsertLotTemplateInfo()
        {
            try
            {
                LotTemplateInfo lotTemplateInfo = new LotTemplateInfo();
                lotTemplateInfo = this.GetLotTemplateInfo4Form(lotTemplateInfo);
                lotTemplateInfo.CreatedBy = base.UserInfo.UserID;
                this.lblMsg.Text = BaseInfoServiceClientProxy.GetInstance().Insert(lotTemplateInfo, "LOT_TEMPLATE") + base.GetGlobalMsgResource("C004");
                base.DataEntityViewState = lotTemplateInfo;
                this.txtLotTemplateID.Enabled = false;
                this.hdnLotTemplateID.Value = this.txtLotTemplateID.Text.Trim();
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = base.GetGlobalMsgResource("C005") + ex.Message;
            }
        }

        private void LoadData()
        {
            this.InitLotTemplateDropDownLit();
            if (!string.IsNullOrEmpty(base.Request.QueryString["ID"]))
            {
                this.hdnLotTemplateID.Value = base.Request.QueryString["ID"].ToString();
                this.SetLotTemplateInfo2Form();
            }
            else
            {
                this.InitLotAttrValueDefaultINOTDDL(this.ddlDefaultIN09, this.ddlDefaultOT09, this.ddlLotValue09.SelectedValue);
            }
            if (!string.IsNullOrEmpty(base.Request.QueryString["from"]))
            {
                this.hdnFrom.Value = base.Request.QueryString["from"].ToString();
            }
            this.chkLotVisible09.Checked = true;
            this.chkLotRFVisible09.Checked = true;
            this.chkLotMandatory09.Checked = true;
            this.chkLotMandatoryOT09.Checked = true;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.LoadData();
                this.txtLot10.Text = "入库通知单号";
                this.txtLot09.Text = "货品属性";
            }
        }

        private void SetLotTemplateInfo2Form()
        {
            try
            {
                string lotTemplateID = this.hdnLotTemplateID.Value;
                LotTemplateInfo lotTemplate = BaseInfoServiceClientProxy.GetInstance().GetInfoByID(lotTemplateID, "LOT_TEMPLATE") as LotTemplateInfo;
                base.DataEntityViewState = lotTemplate;
                if (lotTemplate != null)
                {
                    this.SetLotTemplateInfo2Form(lotTemplate);
                    this.txtLotTemplateID.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = ex.Message;
            }
        }

        private void SetLotTemplateInfo2Form(LotTemplateInfo lotTemplateInfo)
        {
            this.txtLotTemplateID.Text = lotTemplateInfo.LotTemplateID;
            this.txtDescription.Text = lotTemplateInfo.Description;
            this.chkSysCreated.Checked = lotTemplateInfo.SystemCreated == "Y";
            this.chkIsActive.Checked = lotTemplateInfo.IsActive == "Y";
            this.txtSeqNo1.Text = lotTemplateInfo.LotAttr01Seqno.ToString();
            this.txtLot01.Text = lotTemplateInfo.LotAttr01Label;
            this.chkLotVisible01.Checked = lotTemplateInfo.LotAttr01Visible == "Y";
            this.chkLotRFVisible01.Checked = lotTemplateInfo.RfLotAttr01Visible == "Y";
            this.chkLotMandatory01.Checked = lotTemplateInfo.LotAttr01Mandatory == "Y";
            this.chkLotMandatoryOT01.Checked = lotTemplateInfo.LotAttr01MandatoryOT == "Y";
            this.ddlLotType01.SelectedValue = lotTemplateInfo.LotAttr01Type;
            if (this.ddlLotType01.SelectedValue == "OptionList")
            {
                this.ddlLotValue01.SelectedValue = lotTemplateInfo.LotAttr01Value;
                this.ddlLotValue01.Style["display"] = "block";
                this.txtLotValue01.Style["display"] = "none";
                this.InitLotAttrValueDefaultINOTDDL(this.ddlDefaultIN01, this.ddlDefaultOT01, this.ddlLotValue01.SelectedValue);
                this.ddlDefaultIN01.SelectedValue = lotTemplateInfo.LotAttr01ValueDefaultIN;
                this.ddlDefaultIN01.Style["display"] = "block";
                this.txtDefaultIN01.Style["display"] = "none";
                this.ddlDefaultOT01.SelectedValue = lotTemplateInfo.LotAttr01ValueDefaultOT;
                this.ddlDefaultOT01.Style["display"] = "block";
                this.txtDefaultOT01.Style["display"] = "none";
            }
            else
            {
                this.txtLotValue01.Text = lotTemplateInfo.LotAttr01Value;
                this.txtDefaultIN01.Text = lotTemplateInfo.LotAttr01ValueDefaultIN;
                this.txtDefaultOT01.Text = lotTemplateInfo.LotAttr01ValueDefaultOT;
                this.ddlLotValue01.Style["display"] = "none";
                this.txtLotValue01.Style["display"] = "block";
                this.ddlDefaultIN01.Style["display"] = "none";
                this.txtDefaultIN01.Style["display"] = "block";
                this.ddlDefaultOT01.Style["display"] = "none";
                this.txtDefaultOT01.Style["display"] = "block";
            }
            this.txtSeqNo2.Text = lotTemplateInfo.LotAttr02Seqno.ToString();
            this.txtLot02.Text = lotTemplateInfo.LotAttr02Label;
            this.chkLotVisible02.Checked = lotTemplateInfo.LotAttr02Visible == "Y";
            this.chkLotRFVisible02.Checked = lotTemplateInfo.RfLotAttr02Visible == "Y";
            this.chkLotMandatory02.Checked = lotTemplateInfo.LotAttr02Mandatory == "Y";
            this.chkLotMandatoryOT02.Checked = lotTemplateInfo.LotAttr02MandatoryOT == "Y";
            this.ddlLotType02.SelectedValue = lotTemplateInfo.LotAttr02Type;
            if (this.ddlLotType02.SelectedValue == "OptionList")
            {
                this.ddlLotValue02.SelectedValue = lotTemplateInfo.LotAttr02Value;
                this.ddlLotValue02.Style["display"] = "block";
                this.txtLotValue02.Style["display"] = "none";
                this.InitLotAttrValueDefaultINOTDDL(this.ddlDefaultIN02, this.ddlDefaultOT02, this.ddlLotValue02.SelectedValue);
                this.ddlDefaultIN02.SelectedValue = lotTemplateInfo.LotAttr02ValueDefaultIN;
                this.ddlDefaultIN02.Style["display"] = "block";
                this.txtDefaultIN02.Style["display"] = "none";
                this.ddlDefaultOT02.SelectedValue = lotTemplateInfo.LotAttr02ValueDefaultOT;
                this.ddlDefaultOT02.Style["display"] = "block";
                this.txtDefaultOT02.Style["display"] = "none";
            }
            else
            {
                this.txtLotValue02.Text = lotTemplateInfo.LotAttr02Value;
                this.txtDefaultIN02.Text = lotTemplateInfo.LotAttr02ValueDefaultIN;
                this.txtDefaultOT02.Text = lotTemplateInfo.LotAttr02ValueDefaultOT;
                this.ddlLotValue02.Style["display"] = "none";
                this.txtLotValue02.Style["display"] = "block";
                this.ddlDefaultIN02.Style["display"] = "none";
                this.txtDefaultIN02.Style["display"] = "block";
                this.ddlDefaultOT02.Style["display"] = "none";
                this.txtDefaultOT02.Style["display"] = "block";
            }
            this.txtSeqNo3.Text = lotTemplateInfo.LotAttr03Seqno.ToString();
            this.txtLot03.Text = lotTemplateInfo.LotAttr03Label;
            this.chkLotVisible03.Checked = lotTemplateInfo.LotAttr03Visible == "Y";
            this.chkLotRFVisible03.Checked = lotTemplateInfo.RfLotAttr03Visible == "Y";
            this.chkLotMandatory03.Checked = lotTemplateInfo.LotAttr03Mandatory == "Y";
            this.chkLotMandatoryOT03.Checked = lotTemplateInfo.LotAttr03MandatoryOT == "Y";
            this.ddlLotType03.SelectedValue = lotTemplateInfo.LotAttr03Type;
            if (this.ddlLotType03.SelectedValue == "OptionList")
            {
                this.ddlLotValue03.SelectedValue = lotTemplateInfo.LotAttr03Value;
                this.ddlLotValue03.Style["display"] = "block";
                this.txtLotValue03.Style["display"] = "none";
                this.InitLotAttrValueDefaultINOTDDL(this.ddlDefaultIN03, this.ddlDefaultOT03, this.ddlLotValue03.SelectedValue);
                this.ddlDefaultIN03.SelectedValue = lotTemplateInfo.LotAttr03ValueDefaultIN;
                this.ddlDefaultIN03.Style["display"] = "block";
                this.txtDefaultIN03.Style["display"] = "none";
                this.ddlDefaultOT03.SelectedValue = lotTemplateInfo.LotAttr03ValueDefaultOT;
                this.ddlDefaultOT03.Style["display"] = "block";
                this.txtDefaultOT03.Style["display"] = "none";
            }
            else
            {
                this.txtLotValue03.Text = lotTemplateInfo.LotAttr03Value;
                this.txtDefaultIN03.Text = lotTemplateInfo.LotAttr03ValueDefaultIN;
                this.txtDefaultOT03.Text = lotTemplateInfo.LotAttr03ValueDefaultOT;
                this.ddlLotValue03.Style["display"] = "none";
                this.txtLotValue03.Style["display"] = "block";
                this.ddlDefaultIN03.Style["display"] = "none";
                this.txtDefaultIN03.Style["display"] = "block";
                this.ddlDefaultOT03.Style["display"] = "none";
                this.txtDefaultOT03.Style["display"] = "block";
            }
            this.txtSeqNo4.Text = lotTemplateInfo.LotAttr04Seqno.ToString();
            this.txtLot04.Text = lotTemplateInfo.LotAttr04Label;
            this.chkLotVisible04.Checked = lotTemplateInfo.LotAttr04Visible == "Y";
            this.chkLotRFVisible04.Checked = lotTemplateInfo.RfLotAttr04Visible == "Y";
            this.chkLotMandatory04.Checked = lotTemplateInfo.LotAttr04Mandatory == "Y";
            this.chkLotMandatoryOT04.Checked = lotTemplateInfo.LotAttr04MandatoryOT == "Y";
            this.ddlLotType04.SelectedValue = lotTemplateInfo.LotAttr04Type;
            if (this.ddlLotType04.SelectedValue == "OptionList")
            {
                this.ddlLotValue04.SelectedValue = lotTemplateInfo.LotAttr04Value;
                this.ddlLotValue04.Style["display"] = "block";
                this.txtLotValue04.Style["display"] = "none";
                this.InitLotAttrValueDefaultINOTDDL(this.ddlDefaultIN04, this.ddlDefaultOT04, this.ddlLotValue04.SelectedValue);
                this.ddlDefaultIN04.SelectedValue = lotTemplateInfo.LotAttr04ValueDefaultIN;
                this.ddlDefaultIN04.Style["display"] = "block";
                this.txtDefaultIN04.Style["display"] = "none";
                this.ddlDefaultOT04.SelectedValue = lotTemplateInfo.LotAttr04ValueDefaultOT;
                this.ddlDefaultOT04.Style["display"] = "block";
                this.txtDefaultOT04.Style["display"] = "none";
            }
            else
            {
                this.txtLotValue04.Text = lotTemplateInfo.LotAttr04Value;
                this.txtDefaultIN04.Text = lotTemplateInfo.LotAttr04ValueDefaultIN;
                this.txtDefaultOT04.Text = lotTemplateInfo.LotAttr04ValueDefaultOT;
                this.ddlLotValue04.Style["display"] = "none";
                this.txtLotValue04.Style["display"] = "block";
                this.ddlDefaultIN04.Style["display"] = "none";
                this.txtDefaultIN04.Style["display"] = "block";
                this.ddlDefaultOT04.Style["display"] = "none";
                this.txtDefaultOT04.Style["display"] = "block";
            }
            this.txtSeqNo5.Text = lotTemplateInfo.LotAttr05Seqno.ToString();
            this.txtLot05.Text = lotTemplateInfo.LotAttr05Label;
            this.chkLotVisible05.Checked = lotTemplateInfo.LotAttr05Visible == "Y";
            this.chkLotRFVisible05.Checked = lotTemplateInfo.RfLotAttr05Visible == "Y";
            this.chkLotMandatory05.Checked = lotTemplateInfo.LotAttr05Mandatory == "Y";
            this.chkLotMandatoryOT05.Checked = lotTemplateInfo.LotAttr05MandatoryOT == "Y";
            this.ddlLotType05.SelectedValue = lotTemplateInfo.LotAttr05Type;
            if (this.ddlLotType05.SelectedValue == "OptionList")
            {
                this.ddlLotValue05.SelectedValue = lotTemplateInfo.LotAttr05Value;
                this.ddlLotValue05.Style["display"] = "block";
                this.txtLotValue05.Style["display"] = "none";
                this.InitLotAttrValueDefaultINOTDDL(this.ddlDefaultIN05, this.ddlDefaultOT05, this.ddlLotValue05.SelectedValue);
                this.ddlDefaultIN05.SelectedValue = lotTemplateInfo.LotAttr05ValueDefaultIN;
                this.ddlDefaultIN05.Style["display"] = "block";
                this.txtDefaultIN05.Style["display"] = "none";
                this.ddlDefaultOT05.SelectedValue = lotTemplateInfo.LotAttr05ValueDefaultOT;
                this.ddlDefaultOT05.Style["display"] = "block";
                this.txtDefaultOT05.Style["display"] = "none";
            }
            else
            {
                this.txtLotValue05.Text = lotTemplateInfo.LotAttr05Value;
                this.txtDefaultIN05.Text = lotTemplateInfo.LotAttr05ValueDefaultIN;
                this.txtDefaultOT05.Text = lotTemplateInfo.LotAttr05ValueDefaultOT;
                this.ddlLotValue05.Style["display"] = "none";
                this.txtLotValue05.Style["display"] = "block";
                this.ddlDefaultIN05.Style["display"] = "none";
                this.txtDefaultIN05.Style["display"] = "block";
                this.ddlDefaultOT05.Style["display"] = "none";
                this.txtDefaultOT05.Style["display"] = "block";
            }
            this.txtSeqNo6.Text = lotTemplateInfo.LotAttr06Seqno.ToString();
            this.txtLot06.Text = lotTemplateInfo.LotAttr06Label;
            this.chkLotVisible06.Checked = lotTemplateInfo.LotAttr06Visible == "Y";
            this.chkLotRFVisible06.Checked = lotTemplateInfo.RfLotAttr06Visible == "Y";
            this.chkLotMandatory06.Checked = lotTemplateInfo.LotAttr06Mandatory == "Y";
            this.chkLotMandatoryOT06.Checked = lotTemplateInfo.LotAttr06MandatoryOT == "Y";
            this.ddlLotType06.SelectedValue = lotTemplateInfo.LotAttr06Type;
            if (this.ddlLotType06.SelectedValue == "OptionList")
            {
                this.ddlLotValue06.SelectedValue = lotTemplateInfo.LotAttr06Value;
                this.ddlLotValue06.Style["display"] = "block";
                this.txtLotValue06.Style["display"] = "none";
                this.InitLotAttrValueDefaultINOTDDL(this.ddlDefaultIN06, this.ddlDefaultOT06, this.ddlLotValue06.SelectedValue);
                this.ddlDefaultIN06.SelectedValue = lotTemplateInfo.LotAttr06ValueDefaultIN;
                this.ddlDefaultIN06.Style["display"] = "block";
                this.txtDefaultIN06.Style["display"] = "none";
                this.ddlDefaultOT06.SelectedValue = lotTemplateInfo.LotAttr06ValueDefaultOT;
                this.ddlDefaultOT06.Style["display"] = "block";
                this.txtDefaultOT06.Style["display"] = "none";
            }
            else
            {
                this.txtLotValue06.Text = lotTemplateInfo.LotAttr06Value;
                this.txtDefaultIN06.Text = lotTemplateInfo.LotAttr06ValueDefaultIN;
                this.txtDefaultOT06.Text = lotTemplateInfo.LotAttr06ValueDefaultOT;
                this.ddlLotValue06.Style["display"] = "none";
                this.txtLotValue06.Style["display"] = "block";
                this.ddlDefaultIN06.Style["display"] = "none";
                this.txtDefaultIN06.Style["display"] = "block";
                this.ddlDefaultOT06.Style["display"] = "none";
                this.txtDefaultOT06.Style["display"] = "block";
            }
            this.txtSeqNo7.Text = lotTemplateInfo.LotAttr07Seqno.ToString();
            this.txtLot07.Text = lotTemplateInfo.LotAttr07Label;
            this.chkLotVisible07.Checked = lotTemplateInfo.LotAttr07Visible == "Y";
            this.chkLotRFVisible07.Checked = lotTemplateInfo.RfLotAttr07Visible == "Y";
            this.chkLotMandatory07.Checked = lotTemplateInfo.LotAttr07Mandatory == "Y";
            this.chkLotMandatoryOT07.Checked = lotTemplateInfo.LotAttr07MandatoryOT == "Y";
            this.ddlLotType07.SelectedValue = lotTemplateInfo.LotAttr07Type;
            if (this.ddlLotType07.SelectedValue == "OptionList")
            {
                this.ddlLotValue07.SelectedValue = lotTemplateInfo.LotAttr07Value;
                this.ddlLotValue07.Style["display"] = "block";
                this.txtLotValue07.Style["display"] = "none";
                this.InitLotAttrValueDefaultINOTDDL(this.ddlDefaultIN07, this.ddlDefaultOT07, this.ddlLotValue07.SelectedValue);
                this.ddlDefaultIN07.SelectedValue = lotTemplateInfo.LotAttr07ValueDefaultIN;
                this.ddlDefaultIN07.Style["display"] = "block";
                this.txtDefaultIN07.Style["display"] = "none";
                this.ddlDefaultOT07.SelectedValue = lotTemplateInfo.LotAttr07ValueDefaultOT;
                this.ddlDefaultOT07.Style["display"] = "block";
                this.txtDefaultOT07.Style["display"] = "none";
            }
            else
            {
                this.txtLotValue07.Text = lotTemplateInfo.LotAttr07Value;
                this.txtDefaultIN07.Text = lotTemplateInfo.LotAttr07ValueDefaultIN;
                this.txtDefaultOT07.Text = lotTemplateInfo.LotAttr07ValueDefaultOT;
                this.ddlLotValue07.Style["display"] = "none";
                this.txtLotValue07.Style["display"] = "block";
                this.ddlDefaultIN07.Style["display"] = "none";
                this.txtDefaultIN07.Style["display"] = "block";
                this.ddlDefaultOT07.Style["display"] = "none";
                this.txtDefaultOT07.Style["display"] = "block";
            }
            this.txtSeqNo8.Text = lotTemplateInfo.LotAttr08Seqno.ToString();
            this.txtLot08.Text = lotTemplateInfo.LotAttr08Label;
            this.chkLotVisible08.Checked = lotTemplateInfo.LotAttr08Visible == "Y";
            this.chkLotRFVisible08.Checked = lotTemplateInfo.RfLotAttr08Visible == "Y";
            this.chkLotMandatory08.Checked = lotTemplateInfo.LotAttr08Mandatory == "Y";
            this.chkLotMandatoryOT08.Checked = lotTemplateInfo.LotAttr08MandatoryOT == "Y";
            this.ddlLotType08.SelectedValue = lotTemplateInfo.LotAttr08Type;
            if (this.ddlLotType08.SelectedValue == "OptionList")
            {
                this.ddlLotValue08.SelectedValue = lotTemplateInfo.LotAttr08Value;
                this.ddlLotValue08.Style["display"] = "block";
                this.txtLotValue08.Style["display"] = "none";
                this.InitLotAttrValueDefaultINOTDDL(this.ddlDefaultIN08, this.ddlDefaultOT08, this.ddlLotValue08.SelectedValue);
                this.ddlDefaultIN08.SelectedValue = lotTemplateInfo.LotAttr08ValueDefaultIN;
                this.ddlDefaultIN08.Style["display"] = "block";
                this.txtDefaultIN08.Style["display"] = "none";
                this.ddlDefaultOT08.SelectedValue = lotTemplateInfo.LotAttr08ValueDefaultOT;
                this.ddlDefaultOT08.Style["display"] = "block";
                this.txtDefaultOT08.Style["display"] = "none";
            }
            else
            {
                this.txtLotValue08.Text = lotTemplateInfo.LotAttr08Value;
                this.txtDefaultIN08.Text = lotTemplateInfo.LotAttr08ValueDefaultIN;
                this.txtDefaultOT08.Text = lotTemplateInfo.LotAttr08ValueDefaultOT;
                this.ddlLotValue08.Style["display"] = "none";
                this.txtLotValue08.Style["display"] = "block";
                this.ddlDefaultIN08.Style["display"] = "none";
                this.txtDefaultIN08.Style["display"] = "block";
                this.ddlDefaultOT08.Style["display"] = "none";
                this.txtDefaultOT08.Style["display"] = "block";
            }
            this.txtSeqNo9.Text = lotTemplateInfo.LotAttr09Seqno.ToString();
            this.txtLot09.Text = lotTemplateInfo.LotAttr09Label;
            this.chkLotVisible09.Checked = lotTemplateInfo.LotAttr09Visible == "Y";
            this.chkLotRFVisible09.Checked = lotTemplateInfo.RfLotAttr09Visible == "Y";
            this.chkLotMandatory09.Checked = lotTemplateInfo.LotAttr09Mandatory == "Y";
            this.chkLotMandatoryOT09.Checked = lotTemplateInfo.LotAttr09MandatoryOT == "Y";
            this.ddlLotType09.SelectedValue = lotTemplateInfo.LotAttr09Type;
            if (this.ddlLotType09.SelectedValue == "OptionList")
            {
                this.ddlLotValue09.SelectedValue = lotTemplateInfo.LotAttr09Value;
                this.ddlLotValue09.Style["display"] = "block";
                this.txtLotValue09.Style["display"] = "none";
                this.InitLotAttrValueDefaultINOTDDL(this.ddlDefaultIN09, this.ddlDefaultOT09, this.ddlLotValue09.SelectedValue);
                this.ddlDefaultIN09.SelectedValue = lotTemplateInfo.LotAttr09ValueDefaultIN;
                this.ddlDefaultIN09.Style["display"] = "block";
                this.txtDefaultIN09.Style["display"] = "none";
                this.ddlDefaultOT09.SelectedValue = lotTemplateInfo.LotAttr09ValueDefaultOT;
                this.ddlDefaultOT09.Style["display"] = "block";
                this.txtDefaultOT09.Style["display"] = "none";
            }
            else
            {
                this.txtLotValue09.Text = lotTemplateInfo.LotAttr09Value;
                this.txtDefaultIN09.Text = lotTemplateInfo.LotAttr09ValueDefaultIN;
                this.txtDefaultOT09.Text = lotTemplateInfo.LotAttr09ValueDefaultOT;
                this.ddlLotValue09.Style["display"] = "none";
                this.txtLotValue09.Style["display"] = "block";
                this.ddlDefaultIN09.Style["display"] = "none";
                this.txtDefaultIN09.Style["display"] = "block";
                this.ddlDefaultOT09.Style["display"] = "none";
                this.txtDefaultOT09.Style["display"] = "block";
            }
            this.txtSeqNo10.Text = lotTemplateInfo.LotAttr10Seqno.ToString();
            this.txtLot10.Text = lotTemplateInfo.LotAttr10Label;
            this.chkLotVisible10.Checked = lotTemplateInfo.LotAttr10Visible == "Y";
            this.chkLotRFVisible10.Checked = lotTemplateInfo.RfLotAttr10Visible == "Y";
            this.chkLotMandatory10.Checked = lotTemplateInfo.LotAttr10Mandatory == "Y";
            this.chkLotMandatoryOT10.Checked = lotTemplateInfo.LotAttr10MandatoryOT == "Y";
            this.ddlLotType10.SelectedValue = lotTemplateInfo.LotAttr10Type;
            if (this.ddlLotType10.SelectedValue == "OptionList")
            {
                this.ddlLotValue10.SelectedValue = lotTemplateInfo.LotAttr10Value;
                this.ddlLotValue10.Style["display"] = "block";
                this.txtLotValue10.Style["display"] = "none";
                this.InitLotAttrValueDefaultINOTDDL(this.ddlDefaultIN10, this.ddlDefaultOT10, this.ddlLotValue10.SelectedValue);
                this.ddlDefaultIN10.SelectedValue = lotTemplateInfo.LotAttr10ValueDefaultIN;
                this.ddlDefaultIN10.Style["display"] = "block";
                this.txtDefaultIN10.Style["display"] = "none";
                this.ddlDefaultOT10.SelectedValue = lotTemplateInfo.LotAttr10ValueDefaultOT;
                this.ddlDefaultOT10.Style["display"] = "block";
                this.txtDefaultOT10.Style["display"] = "none";
            }
            else
            {
                this.txtLotValue10.Text = lotTemplateInfo.LotAttr10Value;
                this.txtDefaultIN10.Text = lotTemplateInfo.LotAttr10ValueDefaultIN;
                this.txtDefaultOT10.Text = lotTemplateInfo.LotAttr10ValueDefaultOT;
                this.ddlLotValue10.Style["display"] = "none";
                this.txtLotValue10.Style["display"] = "block";
                this.ddlDefaultIN10.Style["display"] = "none";
                this.txtDefaultIN10.Style["display"] = "block";
                this.ddlDefaultOT10.Style["display"] = "none";
                this.txtDefaultOT10.Style["display"] = "block";
            }
            this.txtSeqNo11.Text = lotTemplateInfo.ProduceDateSeqno.ToString();
            this.txtProduct.Text = string.IsNullOrEmpty(lotTemplateInfo.ProduceDateLabel.ToString()) ? "" : lotTemplateInfo.ProduceDateLabel.ToString();
            this.chkLotVisible11.Checked = lotTemplateInfo.ProduceDateVisible == "Y";
            this.chkLotRFVisible11.Checked = lotTemplateInfo.RfProduceDateVisible == "Y";
            this.chkLotMandatory11.Checked = lotTemplateInfo.ProduceDateMandatory == "Y";
            this.chkLotMandatoryOT11.Checked = lotTemplateInfo.ProduceDateMandatoryOT == "Y";
            this.txtSeqNo12.Text = lotTemplateInfo.ExpiryDateSeqno.ToString();
            this.txtExpiryDate.Text = string.IsNullOrEmpty(lotTemplateInfo.ExpiryDateLabel.ToString()) ? "" : lotTemplateInfo.ExpiryDateLabel.ToString();
            this.chkLotVisible12.Checked = lotTemplateInfo.ExpiryDateVisible == "Y";
            this.chkLotRFVisible12.Checked = lotTemplateInfo.RfExpiryDateVisible == "Y";
            this.chkLotMandatory12.Checked = lotTemplateInfo.ExpiryDateMandatory == "Y";
            this.chkLotMandatoryOT12.Checked = lotTemplateInfo.ExpiryDateMandatoryOT == "Y";
            this.txtSeqNo13.Text = lotTemplateInfo.ExternalLotSeqno.ToString();
            this.txtExternal.Text = string.IsNullOrEmpty(lotTemplateInfo.ExternalLotLabel.ToString()) ? "" : lotTemplateInfo.ExternalLotLabel.ToString();
            this.chkLotVisible13.Checked = lotTemplateInfo.ExternalLotVisible == "Y";
            this.chkLotRFVisible13.Checked = lotTemplateInfo.RfExternalLotVisible == "Y";
            this.chkLotMandatory13.Checked = lotTemplateInfo.ExternalLotMandatory == "Y";
            this.chkLotMandatoryOT13.Checked = lotTemplateInfo.ExternalLotMandatoryOT == "Y";
        }

        private void UpdateLotTemplateInfo()
        {
            try
            {
                LotTemplateInfo lotTemplateInfo = base.DataEntityViewState as LotTemplateInfo;
                lotTemplateInfo = this.GetLotTemplateInfo4Form(lotTemplateInfo);
                lotTemplateInfo.UpdatedBy = base.UserInfo.UserID;
                this.lblMsg.Text = BaseInfoServiceClientProxy.GetInstance().Update(lotTemplateInfo, "LOT_TEMPLATE") + base.GetGlobalMsgResource("C002");
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = base.GetGlobalMsgResource("C003") + ex.Message;
            }
        }
    }
}

